home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / smallc.arc / POW.C < prev    next >
Text File  |  1985-07-17  |  1KB  |  37 lines

  1.  
  2. /***********************************************************
  3.  *               The TULSA IBM C BOARD                     *
  4.  *                   918-664-8737                          *
  5.  *             300/1200 XMODEM, 24 Hours                   *
  6.  **********************************************************/
  7.  
  8. #include "math.h"
  9. #include "errno.h"
  10.  
  11. double pow(a,b)
  12. double a,b;
  13. {
  14.         double loga;
  15.         extern int errno;
  16.  
  17.         if (a<=0.0) {
  18.                 if (a<0.0 || a==0.0 && b<=0.0) {
  19.                         errno = EDOM;
  20.                         return -HUGE;
  21.                 }
  22.                 else return 0.0;
  23.         }
  24.         loga = log(a);
  25.         loga *= b;
  26.         if (loga > LOGHUGE) {
  27.                 errno = ERANGE;
  28.                 return HUGE;
  29.         }
  30.         if (loga < LOGTINY) {
  31.                 errno = ERANGE;
  32.                 return 0.0;
  33.         }
  34.         return exp(loga);
  35. }
  36.  
  37.